


if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE "debug")
endif()

if(NOT MUDUO_PATH)
    set(MUDUO_PATH "${CMAKE_CURRENT_SOURCE_DIR}/build/release-install-cpp11")
endif()

#set(CXX_FLAGS
#        -g
#        # -DVALGRIND
#        # -DMUDUO_STD_STRING
#        -Wall
#        -Wextra
#        # -m32
#        -Werror
#        -Wconversion
#        -Wno-unused-parameter
#        -Wold-style-cast
#        -Woverloaded-virtual
#        -Wpointer-arith
#        -Wshadow
#        -Wwrite-strings
#        -march=native
#        # -MMD
#        # -std=c++0x
#        -rdynamic
#        )
string(REPLACE ";" " " CMAKE_CXX_FLAGS "${CXX_FLAGS}")

set(CMAKE_CXX_COMPILER "g++")
set(CMAKE_CXX_FLAGS_DEBUG "-O0")
set(CMAKE_CXX_FLAGS_RELEASE "-O2 -finline-limit=1000 -DNDEBUG")

find_path(Muduo_INCLUDE_DIR muduo "${MUDUO_PATH}/include")
find_path(Muduo_LIBRARY_DIR libmuduo_net.a "${MUDUO_PATH}/lib")
set(CMAKE_LIBRARY_PATH ${CMAKE_LIBRARY_PATH} ${Muduo_LIBRARY_DIR})
message(STATUS ${Muduo_INCLUDE_DIR})
message(STATUS ${Muduo_LIBRARY_DIR})

include_directories(${Muduo_INCLUDE_DIR})
find_library(muduo_base muduo_base)
find_library(muduo_net muduo_net)
message(STATUS ${muduo_base})
message(STATUS ${muduo_net})


find_package(Protobuf REQUIRED)
include_directories(${PROTOBUF_INCLUDE_DIRS})
include_directories(${CMAKE_CURRENT_BINARY_DIR})
PROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS ${CMAKE_CURRENT_SOURCE_DIR}/../proto2_exp/CameraProto.proto)

add_executable(muduo_client muduo_client.cpp ${PROTO_SRCS} ${PROTO_HDRS} )
target_link_libraries(muduo_client ${muduo_net} ${muduo_base} pthread rt ${PROTOBUF_LIBRARIES} ${Boost_LIBRARIES})

add_executable(muduo_server muduo_server.cpp ${PROTO_SRCS} ${PROTO_HDRS} )
target_link_libraries(muduo_server ${muduo_net} ${muduo_base} pthread rt ${PROTOBUF_LIBRARIES} ${Boost_LIBRARIES})



